function main(input) {
    try {
        // 第一层解析：将输入的字符串转为对象
        const wrapper = JSON.parse(input.originalData);
        
        // 第二层解析：获取真正的数据体
        const originalDataFinal = wrapper.data?.[0]; // 直接获取城市数据
        if (!originalDataFinal) {
            throw new Error('无效的城市数据');
        }

        // 获取时间轴并计算长度
        const xData = originalDataFinal.dataTime || [];
        const maxLength = xData.length;

        // 创建带长度参数的系列项
        const createItem = (name, data) => {
            return {
                name,
                type: 'line',
                data: Array.isArray(data) 
                    ? data.slice(0, maxLength).map(v => typeof v === 'number' ? v : null)
                    : new Array(maxLength).fill(null)
            };
        };
	const echartData = [{
					type: "echarts",
					data: {...createChartOption(
xData,
[
                    createItem('PM₂.₅', originalDataFinal.pm25),
                    createItem('PM₁₀', originalDataFinal.pm10),
                    createItem('O₃', originalDataFinal.o3),
                    createItem('NO₂', originalDataFinal.no2),
                    createItem('SO₂', originalDataFinal.so2),
                    createItem('CO', originalDataFinal.co)
                ]

                  )}
				}]
        return {
		
          
        	type: 'chartType',
                data: JSON.stringify(echartData),
        };
    } catch (e) {
        console.error('转换失败:', e);
        return { siteContent: { ...createChartOption([],[]) } };
    }
}
function createChartOption(xData, seriesData) {
  return {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'cross',
        label: {
          backgroundColor: '#6a7985',
          precision: 0,
        },
      },
    },
    legend: {
      top: '10px',
      textStyle: {
        color: '#fff',
      },
    },
    toolbox: {
      show: false,
      feature: {
        saveAsImage: {},
      },
    },
    grid: {
      left: '3%',
      right: '4%',
      bottom: '3%',
      containLabel: true,
    },
    xAxis: [
      {
        type: 'category',
        boundaryGap: false,
        data: xData,
        // 设置字体倾斜
        axisLabel: {
          rotate: 0,
          color: '#fff',
        },
        nameTextStyle: {
          color: '#fff',
        },
      },
    ],
    yAxis: [
      {
        // type: 'log',
        min: 1,
        axisLine: {
          show: 1==1,
          lineStyle: {
            width: 1,
            color: '#999',
          },
        },
        axisTick: {
          show: 1==1,
          lineStyle: {
            color: '#fff',
          },
        },
        axisLabel: {
          color: '#fff',
        },
        // logBase: 5,
        // minInterval: 1
      },
    ],
    series: seriesData,
    color: ['#0096FF', '#27CB75 '],
    dataZoom: [
      {
        id: 'main',
        type: 'inside',
        xAxisIndex: [0],
        filterMode: 'none',
        start: 0,
        end: 100,
      },
    ],
  };
}